(global-set-key [f11]
      (lambda ()
        (interactive)
        (x-send-client-message
         nil 0 nil "_NET_WM_STATE" 32
         '(2 "_NET_WM_STATE_FULLSCREEN" 0))
        )
      )
;;keybindings:
;;----
;;Customized cursor moving bindings.
(global-set-key (kbd "M-k") 'next-line)
(global-set-key (kbd "M-C-k") 'forward-paragraph)
(global-set-key [(meta control K)] 'scroll-up)
(global-set-key (kbd "M-C-S-K") 'scroll-up)
(global-set-key (kbd "M-C-y") 'scroll-up)

(global-set-key (kbd "M-i") 'previous-line)
(global-set-key (kbd "M-C-i") 'backward-paragraph)
(global-set-key (kbd "M-C-S-i") 'scroll-down)
(global-set-key (kbd "M-C-t") 'scroll-down)

(global-set-key (kbd "M-j") 'backward-char)
(global-set-key (kbd "M-C-j") 'backward-word)
(global-set-key (kbd "M-C-S-j") 'move-beginning-of-line)
(global-set-key (kbd "M-C-z") 'move-beginning-of-line)

(global-set-key (kbd "M-l") 'forward-char)
(global-set-key (kbd "M-C-l") 'forward-word)
(global-set-key (kbd "M-C-S-l") 'move-end-of-line)
(global-set-key (kbd "M-s") 'move-end-of-line)

;;----
;;Customized char deleting bindings.
(global-set-key (kbd "M-n") 'backward-delete-char-untabify)
(global-set-key (kbd "M-m") 'backward-delete-char-untabify)
(global-set-key (kbd "M-C-m") 'backward-kill-word)

(global-set-key (kbd "M-,") 'delete-char)
(global-set-key (kbd "M-C-,") 'kill-word)
(global-set-key (kbd "M-f") 'kill-line)
(global-set-key (kbd "M-.") 'kill-word)
(global-set-key (kbd "M-q") 'other-window)
(global-set-key (kbd "M-1") 'delete-other-windows)

;; For switching terms
(global-set-key [(f1)] 'next-buffer)
(global-set-key [(f2)] 'previous-buffer)
;;(global-set-key [(f2)] 'TeX-command-master)
(global-set-key [(f3)] 'TeX-view)

(global-set-key [(f5)] 'gnus)

;----

(global-set-key (kbd "C-M-o") '(lambda () "Move to end and open a newline" (interactive) (move-end-of-line 1)(newline 1)))
;----
(defun uncomment-region (beg end &optional arg)
   (interactive "*r\np")
   (comment-region beg end (- arg)))

(global-set-key "\C-c\C-p" 'uncomment-region)
;----
(defun recentf-open-files-compl ()
  (interactive)
  (let* ((all-files recentf-list)
	 (tocpl (mapcar (function 
			 (lambda (x) (cons (file-name-nondirectory x) x))) all-files))
	 (prompt (append '("File name: ") tocpl))
	 (fname (completing-read (car prompt) (cdr prompt) nil nil)))
    (find-file (cdr (assoc-ignore-representation fname tocpl))))) 

(global-set-key [(control x)(control r)] 'recentf-open-files-compl)
;----
(global-set-key [(meta ?/)] 'hippie-expand)

(setq hippie-expand-try-functions-list 

      '(senator-try-expand-semantic
	try-expand-dabbrev
	try-expand-dabbrev-visible
	try-expand-dabbrev-all-buffers
	try-expand-dabbrev-from-kill
	try-complete-file-name-partially
	try-complete-file-name
	try-expand-all-abbrevs
	try-expand-list
	try-expand-line
	try-expand-line-all-buffers
	try-complete-lisp-symbol-partially
	try-expand-whole-kill
	try-complete-lisp-symbol))
;----
(global-set-key "!" 'match-paren)
          
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
	((looking-at "\\s\)") (forward-char 1) (backward-list 1))
	(t (self-insert-command (or arg 1)))))

;****************************************************************************
(defun wy-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
		     char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))

;;(define-key global-map (kbd "C-c a") 'wy-go-to-char)
;****************************************************************************
;; cursor jump fuction

(global-set-key [(control ?\;)] 'ska-point-to-register)
(global-set-key [(control ?\')] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register. 
Use ska-jump-to-register to jump back to the stored 
position."
  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))

(defun ska-jump-to-register()
  "Switches between current cursorposition and position
that was stored with ska-point-to-register."
  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
        (jump-to-register 8)
        (set-register 8 tmp)))
;****************************************************************************

;;(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(global-set-key [(control tab)] 'semantic-ia-complete-symbol)

(defun copy-lines(&optional arg)
(interactive "p")
(save-excursion
(beginning-of-line)
(set-mark (point))
(if arg
(next-line (- arg 1)))
(end-of-line)
(kill-ring-save (mark) (point))
)
)
;; set key
(global-set-key (kbd "M-n") 'copy-lines) 

(defun fish-capitalize-word(&optional arg)
(interactive )
(backward-word 1)
(capitalize-word 1)
(forward-word)
)
;; set key
;;(global-set-key (kbd "M-c") 'fish-capitalize-word) 



(defun save-and-exit()
(interactive)

(save-buffer)
;;(save-buffer-kill-emacs)
(kill-emacs)
;;(exit)
)

(global-set-key (kbd "M-o") 'save-and-exit) 
